package com.example.demo.model;

import com.example.demo.core.util.ThreadUtil;

import java.util.Objects;

import java.util.Objects;

/**
 * @author yujie
 */
public class TaskRunnable implements Runnable {
    /**
     * 暂定唯一标识
     */
    private final Integer id;

    /**
     * 任务名称
     */
    private final String name;

    /**
     * 任务年龄
     */
    private final Integer age;

    @Override
    public void run() {
        String threadName = ThreadUtil.getThreadName();
        System.out.println(threadName + "--" + id + "--" + name + "--" + age);
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Integer getAge() {
        return age;
    }

    TaskRunnable(Integer id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TaskRunnable that = (TaskRunnable) o;
        return id.equals(that.id) &&
                name.equals(that.name) &&
                age.equals(that.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, age);
    }
}
